
package managedbean;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import session.stateless.HolidayBeanLocal;


@ManagedBean(name="holidayManagerBean")
@ViewScoped


public class HolidayManagerBean {
    @EJB
    private HolidayBeanLocal holidayBeanLocal;
    
    private Date year;
    private Date newYear;
    private Date chineseYear1;
    private Date chineseYear2;
    private Date goodFriday;
    private Date labourDay;
    private Date vesakDay;
    private Date nationalDay;
    private Date puasa;
    private Date haji;
    private Date deepavali;
    private Date christmas;
    private String statusMessage;
    
    DateFormat dayFormat = new SimpleDateFormat("dd");
    DateFormat monthFormat = new SimpleDateFormat("MM");
    DateFormat yearFormat = new SimpleDateFormat("yyyy");
    public HolidayManagerBean() {
    }
    
    public void save(ActionEvent event)            
    {
        
       holidayBeanLocal.createHoliday(yearFormat.format(newYear), monthFormat.format(newYear), dayFormat.format(newYear), "New Year");
       holidayBeanLocal.createHoliday(yearFormat.format(chineseYear1), monthFormat.format(chineseYear1),dayFormat.format(chineseYear1), "Chinese New Year");
       holidayBeanLocal.createHoliday(yearFormat.format(chineseYear2), monthFormat.format(chineseYear2),dayFormat.format(chineseYear2), "Chinese New Year");
       holidayBeanLocal.createHoliday(yearFormat.format(goodFriday), monthFormat.format(goodFriday),dayFormat.format(getChineseYear1()), "Good Friday");
       holidayBeanLocal.createHoliday(yearFormat.format(labourDay), monthFormat.format(labourDay),dayFormat.format(labourDay), "Labour Day");
       holidayBeanLocal.createHoliday(yearFormat.format(vesakDay), monthFormat.format(vesakDay),dayFormat.format(vesakDay), "Vesak Day");
       holidayBeanLocal.createHoliday(yearFormat.format(nationalDay), monthFormat.format(nationalDay),dayFormat.format(nationalDay), "National Day");
       holidayBeanLocal.createHoliday(yearFormat.format(puasa), monthFormat.format(puasa),dayFormat.format(puasa), "Hari Rayah Puasa");
       holidayBeanLocal.createHoliday(yearFormat.format(haji), monthFormat.format(haji),dayFormat.format(haji), "Hari Rayah Haji");
       holidayBeanLocal.createHoliday(yearFormat.format(deepavali), monthFormat.format(deepavali),dayFormat.format(deepavali), "Deepavali");
       holidayBeanLocal.createHoliday(yearFormat.format(christmas), monthFormat.format(christmas),dayFormat.format(christmas), "Christmas");
       
       statusMessage = "Saved Successfully.";
       FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, statusMessage, ""));
       
    }

    public Date getChineseYear1() {
        return chineseYear1;
    }

    public void setChineseYear1(Date chineseYear1) {
        this.chineseYear1 = chineseYear1;
    }

    public Date getChineseYear2() {
        return chineseYear2;
    }

    public void setChineseYear2(Date chineseYear2) {
        this.chineseYear2 = chineseYear2;
    }

    public Date getChristmas() {
        return christmas;
    }

    public void setChristmas(Date christmas) {
        this.christmas = christmas;
    }

    public Date getDeepavali() {
        return deepavali;
    }

    public void setDeepavali(Date deepavali) {
        this.deepavali = deepavali;
    }

    public Date getGoodFriday() {
        return goodFriday;
    }

    public void setGoodFriday(Date goodFriday) {
        this.goodFriday = goodFriday;
    }

    public Date getHaji() {
        return haji;
    }

    public void setHaji(Date haji) {
        this.haji = haji;
    }

    public HolidayBeanLocal getHolidayBeanLocal() {
        return holidayBeanLocal;
    }

    public void setHolidayBeanLocal(HolidayBeanLocal holidayBeanLocal) {
        this.holidayBeanLocal = holidayBeanLocal;
    }

    public Date getLabourDay() {
        return labourDay;
    }

    public void setLabourDay(Date labourDay) {
        this.labourDay = labourDay;
    }

    public Date getNationalDay() {
        return nationalDay;
    }

    public void setNationalDay(Date nationalDay) {
        this.nationalDay = nationalDay;
    }

    public Date getNewYear() {
        return newYear;
    }

    public void setNewYear(Date newYear) {
        this.newYear = newYear;
    }

    public Date getPuasa() {
        return puasa;
    }

    public void setPuasa(Date puasa) {
        this.puasa = puasa;
    }

    public Date getVesakDay() {
        return vesakDay;
    }

    public void setVesakDay(Date vesakDay) {
        this.vesakDay = vesakDay;
    }

    public Date getYear() {
        return year;
    }

    public void setYear(Date year) {
        this.year = year;
    }

    
}
